﻿using System;
using CommonUtils.Logging;
using CommonUtils.Logging.LoggingProviders;

namespace ProcessLauncher
{
    /// <summary>
    /// Process launcher program main class
    /// </summary>
    internal class ProcessLauncherProgram
    {
        /// <summary>
        /// Entry point
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            using (Logger.Instance)
            {
                Logger.Instance.AddLoggingProvider(new FileLoggingProvider(MessageType.Debug));
#if DEBUG
                Logger.Instance.AddLoggingProvider(new ConsoleLoggingProvider(MessageType.Debug));
#else
                Logger.Instance.AddLoggingProvider(new ConsoleLoggingProvider(MessageType.Output));
#endif
                Logger.Instance.LogMessage("Started");
                try
                {
                    new ProcessLauncherCommandLineHandler(args).Execute();
                }
                catch (Exception e)
                {
                    Logger.Instance.LogMessage(e);
                    Logger.Instance.LogMessage("Finished with error");
                    return;
                }
                Logger.Instance.LogMessage("Finished correctly");
            }
        }
    }
}